package cn.classyex.business.hr.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import cn.classyex.business.hr.domain.WelfareInOutRecord;
import cn.classyex.business.hr.service.IWelfareInOutRecordService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 福利基金进出记录管理Controller
 * 
 * @author yex
 * @date 2021-05-06
 */
@Controller
@RequestMapping("/hr/welfareInOutRecord")
public class WelfareInOutRecordController extends BaseController
{
    private String prefix = "hr/welfareInOutRecord";

    @Autowired
    private IWelfareInOutRecordService welfareInOutRecordService;

    @RequiresPermissions("hr:welfareInOutRecord:view")
    @GetMapping()
    public String welfareInOutRecord()
    {
        return prefix + "/welfareInOutRecord";
    }

    /**
     * 查询福利基金进出记录管理列表
     */
    @RequiresPermissions("hr:welfareInOutRecord:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(WelfareInOutRecord welfareInOutRecord)
    {
        startPage();
        List<WelfareInOutRecord> list = welfareInOutRecordService.selectWelfareInOutRecordList(welfareInOutRecord);
        return getDataTable(list);
    }

    /**
     * 导出福利基金进出记录管理列表
     */
    @RequiresPermissions("hr:welfareInOutRecord:export")
    @Log(title = "福利基金进出记录管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(WelfareInOutRecord welfareInOutRecord)
    {
        List<WelfareInOutRecord> list = welfareInOutRecordService.selectWelfareInOutRecordList(welfareInOutRecord);
        ExcelUtil<WelfareInOutRecord> util = new ExcelUtil<WelfareInOutRecord>(WelfareInOutRecord.class);
        return util.exportExcel(list, "福利基金进出记录管理数据");
    }

    /**
     * 新增福利基金进出记录管理
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存福利基金进出记录管理
     */
    @RequiresPermissions("hr:welfareInOutRecord:add")
    @Log(title = "福利基金进出记录管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(WelfareInOutRecord welfareInOutRecord)
    {
        return toAjax(welfareInOutRecordService.insertWelfareInOutRecord(welfareInOutRecord));
    }

    /**
     * 修改福利基金进出记录管理
     */
    @GetMapping("/edit/{welfareInOutRecordId}")
    public String edit(@PathVariable("welfareInOutRecordId") Long welfareInOutRecordId, ModelMap mmap)
    {
        WelfareInOutRecord welfareInOutRecord = welfareInOutRecordService.selectWelfareInOutRecordById(welfareInOutRecordId);
        mmap.put("welfareInOutRecord", welfareInOutRecord);
        return prefix + "/edit";
    }

    /**
     * 修改保存福利基金进出记录管理
     */
    @RequiresPermissions("hr:welfareInOutRecord:edit")
    @Log(title = "福利基金进出记录管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(WelfareInOutRecord welfareInOutRecord)
    {
        return toAjax(welfareInOutRecordService.updateWelfareInOutRecord(welfareInOutRecord));
    }

    /**
     * 删除福利基金进出记录管理
     */
    @RequiresPermissions("hr:welfareInOutRecord:remove")
    @Log(title = "福利基金进出记录管理", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(welfareInOutRecordService.deleteWelfareInOutRecordByIds(ids));
    }
}
